package test;

import java.net.InetAddress;
import java.net.UnknownHostException;

import lime2.LimeServerID;
import lime2.TupleID;
import sagroup.dracots.DracoTS;
import sagroup.dracots.DracoTuple;
import sagroup.dracots.FlatShareTuple;
import sagroup.dracots.ShareTuple;

public class InAgent implements Runnable {
	public void run() {
		DracoTS dts = DracoTS.get("testing");
		TupleID tid = null;
		try {
			tid = new TupleID(new LimeServerID(InetAddress.getLocalHost(), 30000), 2);
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		ShareTuple template = ShareTuple.createVIDTemplate(tid);
		
		template.setReplica(false);
		DracoTuple ret = dts.in(template);
		if (ret != null) {
			System.out.println("InAgent has read and delete tuple with vid: "
					+ ret.getVID());
		}
		if(dts.rdp(template) == null){
			System.out.println("Tuple is deleted!");
		}
		System.out.println("InAgent finished!");
	}
}
